package com.hhu.wangzb.server.service.impl;

import com.hhu.wangzb.common.entity.UserEntity;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hhu.wangzb.common.utils.PageUtils;
import com.hhu.wangzb.common.utils.Query;

import com.hhu.wangzb.server.dao.UserPermissionDao;
import com.hhu.wangzb.common.entity.UserPermissionEntity;
import com.hhu.wangzb.server.service.UserPermissionService;


@Service("userPermissionService")
public class UserPermissionServiceImpl extends ServiceImpl<UserPermissionDao, UserPermissionEntity> implements UserPermissionService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<UserPermissionEntity> page = this.page(
                new Query<UserPermissionEntity>().getPage(params),
                new QueryWrapper<UserPermissionEntity>()
        );

        return new PageUtils(page);
    }


    @Override
    public UserPermissionEntity queryOneByParamsMap(Map<String, Object> paramsMap) {

        QueryWrapper<UserPermissionEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.allEq(paramsMap);

        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public List<UserPermissionEntity> queryListByParamsMap(Map<String, Object> paramsMap) {

        QueryWrapper<UserPermissionEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.allEq(paramsMap);

        return baseMapper.selectList(queryWrapper);
    }

}